// pages/detail/detail.js

const app = getApp()
const api = require("../../../utils/util")
var WxParse = require('../../../wxParse/wxParse.js');
Page({
    // 页面分享
    onShareAppMessage () {},
    // 分享朋友圈
    onShareTimeline () {},

    /**
     * 页面的初始数据
     */
    data: {
      imagesUrl: app.globalData.siteUrl,
      form:{
        url:'',
        title: '',
        date: '',
        address: '',
        category: '',
        introduction: '',
        id: '',
        ucode:'',
        companyName: '',
        companyId: '',
        pic:''
      },
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

      
    


      if(options.id){
        let param = {
          id: options.id
        }
        let that = this
        let {form} = this.data
        api.supply1_one(param).then(function(res){
            form.id = res.data.id;
            form.url = app.globalData.siteUrl + res.data.url
            form.title = res.data.title;
            form.address = res.data.address;
            form.date = res.data.date;
            form.category = res.data.category;
            form.introduction = res.data.introduction;
            form.ucode = res.data.ucode;
            if(res.data.pic){
              form.pic = app.globalData.siteUrl + res.data.pic
            }
            
            that.setData({
              form,
              value02: res.data.category
            }, ()=>{
              WxParse.wxParse('article', 'html', form.introduction, that, 0);
            })

            let param1 = {
              ucode: res.data.ucode
            }
            api.get_enterprise(param1).then(function(res1){
                let form1 = that.data.form
                form1.companyName = res1.data.name;
                form1.companyId = res1.data.id;
                that.setData({
                   form: form1
                })
            })
        })
      }


      if(options.message_id){
        let param2 = {
          id:options.message_id
        }
        api.memberSupply1_read(param2).then(function(res){
          
        })
      }
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },

    submitHandle: function(){
      wx.redirectTo({
        url: '/pages/search/sEnterprise/sEnterprise?id=' + this.data.form.companyId,
      })
   }
})